package com.shanzhi.connection.common;

import okhttp3.Request;

import java.util.Map;

public class MapUtils {

    @FunctionalInterface
    public interface HeaderSetter<T> {
        void setHeader(String key, String value, T target);
    }

    public static <T> void setHeaders(Map<String, String> headers, T target, HeaderSetter<T> setter) {
        if (headers == null) return;
        for (Map.Entry<String, String> entry : headers.entrySet()) {
            setter.setHeader(entry.getKey(), entry.getValue(), target);
        }
    }
}
